<?php

namespace DP\AbstractFactory\Factories;

use Exception;
use DP\AbstractFactory\Factories\Abstracts\AbstractFactory;

class ShapeFactory extends AbstractFactory
{
    public function getColorFactory($color)
    {

    }

    public function getShapeFactory($shape)
    {
        if (!$shape) {
            return null;
        }

        $shape = ucfirst(strtolower($shape));
        $class = 'DP\AbstractFactory\Worker\Color\\' . $shape . 'Color';

        try {
            return new $class();
        } catch (Exception $e) {
            echo '实例化失败，错误信息：' . $e->getMessage();
            return null;
        }
    }

}